﻿
namespace KlearTweet.Client.Tab
{
    public partial class TabHeader
    {
        public event System.EventHandler OmniBoxDropDownToggleClicked;

        public TabHeader()
        {
            InitializeComponent();
            SetProgressBar(false, false);
        }

        private void DropDownToggle_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var handler = OmniBoxDropDownToggleClicked;
            if (handler != null)
                handler(sender, e);
        }

        public void SetProgressBar(bool searching, bool failed)
        {
            Infrastructure.ThreadPoolHelper.RunOnMainThread(() =>
            {
                if (searching)
                {
                    ProgressBar.IsIndeterminate = true;
                    ProgressBar.Background = SearchingBrush;
                }
                else
                {
                    ProgressBar.IsIndeterminate = false;
                    ProgressBar.Background = failed ? FailedBrush : DefaultBrush; // TODO: Add SelectedDefaultBrush (for the current tab)
                }
            });
        }
    }
}
